package com.xbh.Book.dao.impl;

import com.xbh.Book.dao.UserDao;
import com.xbh.Book.pojo.User;

/**
 * @program: JavaWebExer
 * @description:
 * @author: 许宝华
 * @create: 2021-04-03 16:39
 */

public class UserDaoImpl extends BaseDao implements UserDao {

    @Override
    public User queryUserByUsername(String username) {
        String sql="select id,username,PASSWORD,email from t_user where username= ?";
//      String sql="SELECT id,username,PASSWORD,email FROM t_user WHERE username=\"admin\"";
        return queryForOne(User.class,sql,username);
    }

    @Override
    public int saveUser(User user) {
        String sql="insert into t_user(username,PASSWORD,email) VALUES(?,?,?)";
        return update(sql,user.getUsername(),user.getPassword(),user.getEmail());
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        String sql="select id,username,password,email from t_user where username=? and password=?";
        return queryForOne(User.class,sql,username,password);
    }
}
